package starcoast.bocai.com.starcoast.fragments;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import butterknife.Bind;
import butterknife.ButterKnife;
import starcoast.bocai.com.starcoast.R;
import starcoast.bocai.com.starcoast.activitys.user.CommonProblemActivity;
import starcoast.bocai.com.starcoast.activitys.user.ModifyActivity;
import starcoast.bocai.com.starcoast.activitys.user.MyMovableActivity;
import starcoast.bocai.com.starcoast.activitys.user.MyOrderActivity;
import starcoast.bocai.com.starcoast.activitys.user.MyTopicActivity;
import starcoast.bocai.com.starcoast.activitys.user.PropertyActivity;
import starcoast.bocai.com.starcoast.activitys.user.ReservationActivity;
import starcoast.bocai.com.starcoast.activitys.user.SetActivity;
import starcoast.bocai.com.starcoast.common.BaseFragment;

/**
 * Created by admin on 2016/6/3.
 */
public class UserFragment extends BaseFragment implements View.OnClickListener {
    @Bind(R.id.tv_title)
    TextView mTitleTv;
    @Bind(R.id.toolbar)
    Toolbar toolbar;
    @Bind(R.id.user_modify)
    LinearLayout user_modify;
    @Bind(R.id.my_movable)
    LinearLayout my_movable;
    @Bind(R.id.my_topic)
    LinearLayout my_topic;
    @Bind(R.id.my_order)
    LinearLayout my_order;
    @Bind(R.id.my_reservation)
    LinearLayout my_reservation;
    @Bind(R.id.user_my_property)
    LinearLayout user_my_property;
    @Bind(R.id.user_safe)
    LinearLayout user_safe;
    @Bind(R.id.user_common_problem)
    LinearLayout user_common_problem;
    View view;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_user, container, false);
        ButterKnife.bind(this, view);
        initView();
        return view;
    }
    public void initView(){
        mTitleTv.setText(R.string.str_frag_user);
        toolbar.inflateMenu(R.menu.menu_set);
        toolbar.setBackgroundColor(getResources().getColor(R.color.color_transparent));
        toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                startActivity(new Intent(getActivity(), SetActivity.class));
                return false;
            }
        });
        user_modify.setOnClickListener(this);
        my_movable.setOnClickListener(this);
        my_topic.setOnClickListener(this);
        my_order.setOnClickListener(this);
        my_reservation.setOnClickListener(this);
        user_my_property.setOnClickListener(this);
        user_safe.setOnClickListener(this);
        user_common_problem.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
            switch (v.getId()){
            case R.id.user_modify:
                startActivity(new Intent(getActivity(), ModifyActivity.class));
                break;
            case R.id.my_movable:
                startActivity(new Intent(getActivity(), MyMovableActivity.class));
                break;
            case R.id.my_topic:
                startActivity(new Intent(getActivity(), MyTopicActivity.class));
                break;
            case R.id.my_order:
                startActivity(new Intent(getActivity(), MyOrderActivity.class));
                break;
            case R.id.my_reservation:
                startActivity(new Intent(getActivity(), ReservationActivity.class));
                break;
            case R.id.user_my_property:
                startActivity(new Intent(getActivity(), PropertyActivity.class));
                break;
            case R.id.user_safe:
                startActivity(new Intent(getActivity(), ReservationActivity.class));
                break;
            case R.id.user_common_problem:
                 startActivity(new Intent(getActivity(), CommonProblemActivity.class));
                 break;

        }
    }
}
